import { defineStore } from "pinia";

export const useDrag = defineStore("drag", {
  state: ():  IStdO => ({
    dragCurrent:null,
    renderData: [],
    registerConfig: { componentList: [], componentMap: {} },
    dragStyle: "",
    clickItem: null,
    clickItemCopy: null,
    enterItem: null,
  clickParent:null ,
  leaveItem: null,
    refList: {},
    currentForm: null,
    enter: false,
    clickItemSettings: null
  }),
  actions: {
    allReset() {
      this.dragReset();
      this.clickReset();
      this.renderData = [];
      nextTick(() => {
        this.refList = {};
      });
    },
    dragReset() {
      this.dragStyle = "";
      this.dragCurrent = null;
      if (this.leaveItem) {
        this.leaveItem.leaveElement = false;
        this.leaveItem = null;
      }
      if (this.enterItem) {
        this.enterItem.click = false;
        this.enterItem = null;
      }
      this.enter = false;
    },
    clickReset() {
      this.currentForm = null;
      this.clickItemCopy = null;
      this.clickItemSettings = null;
      this.clickItem = null;
      this.clickParent = null;
    }
  },
  persist: []
});
